﻿Imports System.Windows.Forms

Public Class DateBox
    Public TextBoxPemintaTanggal As Object
    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub MonthCalendar1_DateSelected(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateSelected
        Try
            Dim v As Date = MonthCalendar1.SelectionStart.Date
            Dim FormatTgl As String = "yyyy-MM-dd"
            If FormatTgl = "" Then FormatTgl = "yyyy-MM-dd"
            CType(TextBoxPemintaTanggal, TextBox).Text = Format(v, FormatTgl)
            CType(TextBoxPemintaTanggal, TextBox).Focus()
            Me.Close()
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try

    End Sub

    Private Sub F99_DateBox_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With MonthCalendar1
            .Left = .Left : .Top = .Top + .Height : .MaxSelectionCount = 1 : .Name = "mntview"
            .BackColor = Color.Lavender
        End With
    End Sub
End Class
